<?php
define('PABLO_AUTH', true);
define('DIR', dirname(__FILE__) . '/');
define('COREDIR', dirname(__FILE__) . '/' . 'pablo-core/');
define('PACKAGEDIR', dirname(__FILE__) . '/' . 'pablo-packages/');

// First, load all classes
foreach (scandir(COREDIR) as $file)
{
	if (substr($file, -10) == '.class.php')
	{
		require_once COREDIR . $file;
	}
}

echo '<pre>' . Spyc::YAMLDump(array(
	'group' => 'blog',
	'routes' => array(
		'page' => array(
			'[continue]' => array(
				'%page_slug%' => array(
					'[leaf]' => array(
						'query' => 'type=page + post.slug={$page_slug}'
					),
				),
			),
		),
		'%year%' => array(
			'[leaf]' => array(
				'query' => 'type=post + post.daterange(year:{$year})'
			),
			'[continue]' => array(
				'%month%' => array(
					'[leaf]' => array(
						'query' => 'type=post + post.daterange(year:{$year}, month:{$month})'
					),
					'[continue]' => array(
						'%day%' => array(
							'[leaf]' => array(
								'query' => 'type=post + post.daterange(year:{$year}, month:{$month}, day:{$day})'
							),
							'[continue]' => array(
								'%post_slug%' => array(
									'[leaf]' => array(
										'query' => 'type=post + post.slug={$post_slug}'
									),
								),
							),
						),
					),
				),
			),
		),
	),
	'validation' => array(
		'%year%' => 'some_callback',
		'%month%' => 'some_other_callback',
		'%day%' => 'yet_another_callback',
		'%post_slug%' => 'validate_post_slug',
		'%page_slug%' => 'validate_page_slug',
	),
), 4);

echo Type_Post::filter_daterange(array(
	'year' => '2010',
	'month' => '05'
));

die();

$R = new Router('particlepress');

$R->setMainGroup('particlepress');

$query = $R->parseURI('2010/05/03');
echo $query;

// Then, setup the pablo singleton
//$Pablo = Pablo::getSingletonInstance();

/*
$Pablo->registerType(new Type(array(
	'id' => 'text',
	'description' => 'This is the base text type.',
	//'abstract' => true,
	'datafields' => array(
		'title' => 'VARCHAR(200)',
		'content' => 'TEXT'
	),
	'parents' => array(
		'particle' => $Pablo->getType('particle')
	)
)));

$Pablo->registerType(new Type(array(
	'id' => 'post',
	'description' => '',
	//'abstract' => true,
	'datafields' => array(
	),
	'parents' => array(
		'text' => $Pablo->getType('text')
	)
)));

echo '<pre>';
print_r($Pablo->getType('post')->getElders());
print_r($Pablo->getType('text')->getSiblings());
*/


//echo '<pre>';
//print_r(SPYC::YAMLLoad(DIR . 'pablo-packages/tutorenpantarijn/package.yaml'));

?>